import QtQuick 2.12

WebSocket{
    id:socket
    url:"ws://localhost:8090"
    active: true
    onTextMessageReceived: function(message){
        console.log(message)
        console.log(JSON.stringify( message))
        var msg= JSON.parse(message)
        console.log("接收到的消息主体:"+msg)
        console.log(msg.message)

    }
    onStatusChanged: {
        // console.log(socket.errorString)
        // console.log(socket.status)
        // console.log(socket.status==WebSocket.Open)
        if(socket.status==WebSocket.Open){
            //建立链接成功,立刻测试
            socket.sendTextMessage(JSON.stringify( {"code":10001,"nickname":"系统联通测试消息","userid":111}))
            socket.sendTextMessage(JSON.stringify( {"code":10002,"nickname":"系统联通测试消息","userid":111,"type":1,"fromId":111,"msgId":"asdhjkashdjk","phone":"17760659134","msgcontent":"你好嘛 宝贝?","nickname":"金箍棒","toId":111}))
        }

    }

}
